package com.coai.user.dto

import com.coai.user.model.UserRole
import com.coai.user.model.UserStatus
import jakarta.validation.constraints.Email
import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.Size
import java.time.LocalDateTime

data class UserDto(
    val id: String,
    val username: String,
    val email: String,
    val displayName: String?,
    val avatar: String?,
    val phone: String?,
    val status: UserStatus,
    val role: UserRole,
    val enabled: Boolean,
    val lastLoginAt: LocalDateTime?,
    val createdAt: LocalDateTime
)

data class RegisterRequest(
    @field:NotBlank(message = "用户名不能为空")
    @field:Size(min = 3, max = 50, message = "用户名长度必须在3-50之间")
    val username: String,
    
    @field:NotBlank(message = "邮箱不能为空")
    @field:Email(message = "邮箱格式不正确")
    val email: String,
    
    @field:NotBlank(message = "密码不能为空")
    @field:Size(min = 6, max = 100, message = "密码长度必须在6-100之间")
    val password: String,
    
    val displayName: String? = null
)

data class LoginRequest(
    @field:NotBlank(message = "用户名或邮箱不能为空")
    val usernameOrEmail: String,
    
    @field:NotBlank(message = "密码不能为空")
    val password: String
)

data class LoginResponse(
    val token: String,
    val user: UserDto,
    val expiresIn: Long
)

data class UpdateUserRequest(
    val displayName: String?,
    val avatar: String?,
    val phone: String?
)

data class ChangePasswordRequest(
    @field:NotBlank(message = "旧密码不能为空")
    val oldPassword: String,
    
    @field:NotBlank(message = "新密码不能为空")
    @field:Size(min = 6, max = 100, message = "新密码长度必须在6-100之间")
    val newPassword: String
)

data class UpdateStatusRequest(
    val status: UserStatus
)
